New functions to disable/enable individual loaders and to obtain license
authorMatthias Clasen <maclas@gmx.de>
Thu, 8 Jul 2004 03:56:36 +0000 (03:56 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 8 Jul 2004 03:56:36 +0000 (03:56 +0000)
Wed Jul  7 23:53:58 2004  Matthias Clasen  <maclas@gmx.de>

* gdk-pixbuf-io.h:
* gdk-pixbuf-io.c (gdk_pixbuf_format_is_disabled):
* gdk-pixbuf-io.c (gdk_pixbuf_format_set_disabled):
* gdk-pixbuf-io.c (gdk_pixbuf_format_get_license):
New functions to disable/enable individual loaders and to
obtain license information about loaders.

* gdk-pixbuf-io.h (GdkPixbufFormat): Add disabled and
license fields.

* gdk-pixbuf-io.c (_gdk_pixbuf_get_module):
* gdk-pixbuf-io.c (_gdk_pixbuf_get_named_module): Skip
disabled loaders.

* io-*.c: Add license information in the fill_info
functions.

17 files changed:
gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/io-ani.c
gdk-pixbuf/io-bmp.c
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-ico.c
gdk-pixbuf/io-jpeg.c
gdk-pixbuf/io-pcx.c
gdk-pixbuf/io-png.c
gdk-pixbuf/io-pnm.c
gdk-pixbuf/io-ras.c
gdk-pixbuf/io-tga.c
gdk-pixbuf/io-tiff.c
gdk-pixbuf/io-wbmp.c
gdk-pixbuf/io-xbm.c
gdk-pixbuf/io-xpm.c

index b34317402911961363be6f6623aefe012939156d..dcc570264c3ea180c4db21a48ae7d41fb411d4d1 100644 (file)
@@ -1,3 +1,22 @@
+Wed Jul  7 23:53:58 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gdk-pixbuf-io.h: 
+       * gdk-pixbuf-io.c (gdk_pixbuf_format_is_disabled): 
+       * gdk-pixbuf-io.c (gdk_pixbuf_format_set_disabled): 
+       * gdk-pixbuf-io.c (gdk_pixbuf_format_get_license): 
+       New functions to disable/enable individual loaders and to
+       obtain license information about loaders.
+       
+       * gdk-pixbuf-io.h (GdkPixbufFormat): Add disabled and 
+       license fields.
+
+       * gdk-pixbuf-io.c (_gdk_pixbuf_get_module): 
+       * gdk-pixbuf-io.c (_gdk_pixbuf_get_named_module): Skip
+       disabled loaders.
+
+       * io-*.c: Add license information in the fill_info
+       functions.
+       
 2004-07-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk-pixbuf-features.h.in: Fix the build.
index 7cd9184569fbe686534426e9e6247897299562fc..c6a3ea1a2c013d410bdcbac08c88a832e4c21975 100644 (file)
@@ -615,6 +615,10 @@ _gdk_pixbuf_get_named_module (const char *name,
 
        for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
                GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
+
+               if (module->info->disabled)
+                       continue;
+
                if (!strcmp (name, module->module_name))
                        return module;
        }
@@ -641,6 +645,10 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
 
        for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
                GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
+
+               if (module->info->disabled)
+                       continue;
+
                score = format_check (module, buffer, size);
                if (score > best) {
                        best = score; 
@@ -1843,6 +1851,67 @@ gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format)
        return (format->flags & GDK_PIXBUF_FORMAT_SCALABLE) != 0;
 }
 
+/**
+ * gdk_pixbuf_format_is_disabled:
+ * @format: a #GdkPixbufFormat
+ *
+ * Returns whether this image format is disabled. See
+ * gdk_pixbuf_format_set_disabled().
+ * 
+ * Return value: whether this image format is disabled.
+ *
+ * Since: 2.6
+ */
+gboolean   
+gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format)
+{
+       g_return_val_if_fail (format != NULL, FALSE);
+
+       return format->disabled;        
+}
+
+/**
+ * gdk_pixbuf_format_set_disabled:
+ * @format: a #GdkPixbufFormat
+ * @disabled: %TRUE to disable the format @format
+ *
+ * Disables or enables an image format. If a format is disabled, 
+ * gdk-pixbuf won't use the image loader for this format to load 
+ * images. Applications can use this to avoid using image loaders 
+ * with an inappropriate license, see gdk_pixbuf_format_get_license().
+ *
+ * Since: 2.6
+ */
+void 
+gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format,
+                               gboolean         disabled)
+{
+       g_return_val_if_fail (format != NULL, FALSE);
+       
+       format->disabled = disabled != FALSE;
+}
+
+/**
+ * gdk_pixbuf_format_get_license:
+ * @format: a #GdkPixbufFormat
+ *
+ * Returns information about the license of the image loader
+ * for the format. The returned string should be a shorthand for 
+ * a wellknown license, e.g. "LGPL", "GPL", "QPL", "GPL/QPL",
+ * or "other" to indicate some other license.  
+ *
+ * Returns: a string describing the license of @format. 
+ *
+ * Since: 2.6
+ */
+gchar*
+gdk_pixbuf_format_get_license (GdkPixbufFormat *format)
+{
+       g_return_val_if_fail (format != NULL, FALSE);
+
+       return g_strdup (format->license);
+}
+
 GdkPixbufFormat *
 _gdk_pixbuf_get_format (GdkPixbufModule *module)
 {
index 27a17b3a4bafc5a8f04c161447a9a39d8efe1352..3eafd5f82ec700064ab523b7516f68db05ce8d88 100644 (file)
@@ -39,17 +39,21 @@ G_BEGIN_DECLS
 
 typedef struct _GdkPixbufFormat GdkPixbufFormat;
  
-GSList    *gdk_pixbuf_get_formats (void);
+GSList    *gdk_pixbuf_get_formats            (void);
 gchar     *gdk_pixbuf_format_get_name        (GdkPixbufFormat *format);
 gchar     *gdk_pixbuf_format_get_description (GdkPixbufFormat *format);
 gchar    **gdk_pixbuf_format_get_mime_types  (GdkPixbufFormat *format);
 gchar    **gdk_pixbuf_format_get_extensions  (GdkPixbufFormat *format);
 gboolean   gdk_pixbuf_format_is_writable     (GdkPixbufFormat *format);
 gboolean   gdk_pixbuf_format_is_scalable     (GdkPixbufFormat *format);
+gboolean   gdk_pixbuf_format_is_disabled     (GdkPixbufFormat *format);
+void       gdk_pixbuf_format_set_disabled    (GdkPixbufFormat *format,
+                                             gboolean         disabled);
+gchar     *gdk_pixbuf_format_get_license     (GdkPixbufFormat *format);
 
-GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar  *filename,
-                                          gint         *width, 
-                                          gint         *height);
+GdkPixbufFormat *gdk_pixbuf_get_file_info    (const gchar     *filename,
+                                             gint            *width, 
+                                             gint            *height);
 
 #ifdef GDK_PIXBUF_ENABLE_BACKEND
 
@@ -151,6 +155,8 @@ struct _GdkPixbufFormat {
   gchar **mime_types;
   gchar **extensions;
   guint32 flags;
+  gboolean disabled;
+  gchar *license;
 };
 
 
index 00a9fc11b376e8f8efd9a1a9090f4973259d3294..5e7b6beb91b0f6ca0eb2c09908631b9fe8156349 100644 (file)
@@ -677,6 +677,7 @@ MODULE_ENTRY (ani, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
 
 
index d43bed95a5593e567e0b2bb539a5b8f2ab766d74..d79e5be03c7726c9d5f5f935148283d923ba9493 100644 (file)
@@ -1119,5 +1119,6 @@ MODULE_ENTRY (bmp, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
 
index 8dd73bde05841f2ccebd010cfca92b21af8b5df6..7df855d9e5accb1958b47faafcf08a25cd57b7ea 100644 (file)
@@ -1651,4 +1651,5 @@ MODULE_ENTRY (gif, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index e19f86f8f7096214704da07fa791de5c8edb4d2f..a7bcbb4c7173c735196c4c3e0583ce6d6dd992c2 100644 (file)
@@ -1203,6 +1203,7 @@ MODULE_ENTRY (ico, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+       info->license = "LGPL";
 }
 
 
index 82acc7d1397d9427b77d13560f441adc041567c0..1a42feeb6bdb9a8f4f9d0095b223686b151d2f3d 100644 (file)
@@ -1070,4 +1070,5 @@ MODULE_ENTRY (jpeg, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+       info->license = "LGPL";
 }
index 4904f3acf84a130ef3a8b2c1d9090bde2882157e..6b4417403345951501b71b2a9ca080893a990c76 100644 (file)
@@ -759,4 +759,5 @@ MODULE_ENTRY (pcx, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index 669cb7bfc541f71dfe8000791c9c97f97fc37bd1..df5417db3011fc09cdef1178685c67d6afe48b39 100644 (file)
@@ -995,4 +995,5 @@ MODULE_ENTRY (png, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = GDK_PIXBUF_FORMAT_WRITABLE;
+       info->license = "LGPL";
 }
index d65bb3da55d434ce77e43c1691f0db15d67495f4..7d94014501cca62a3dab91f48ef9531239dd5a36 100644 (file)
@@ -1083,4 +1083,5 @@ MODULE_ENTRY (pnm, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index 40ba370d53d094598a4fa683b00518bf9e6d49df..9fe936161ec3460f4860687af0b48e3aba5ccefd 100644 (file)
@@ -544,5 +544,6 @@ MODULE_ENTRY (ras, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
 
index ef49e79315bb0f2699ea11d6f748a725524fa860..f4102bdf20ed1b9a7cce544567029c38267f8aef 100644 (file)
@@ -996,4 +996,5 @@ MODULE_ENTRY (tga, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index 0acdd091da12092f5c76575bd1e49c248fdb5b99..72c50fc61f9073c6d641c03fec430e40c0a486d6 100644 (file)
@@ -626,4 +626,5 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index afcad336f5e05b1921240c3b74c4a99ee59d2ccd..098c8c805d2e84741ad4b1809ddc758aa193f7d1 100644 (file)
@@ -369,4 +369,5 @@ MODULE_ENTRY (wbmp, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index 060339d156233d41da5dde0349c592ff52481a1b..45d4be79edf49136a18461eb67443a4315eb075b 100644 (file)
@@ -477,4 +477,5 @@ MODULE_ENTRY (xbm, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }
index 40cd525f39d4a5b8bf7c8e6ab22d8a7a59644737..636d759e9a9aee87ca510a21620f040a7cdc8b44 100644 (file)
@@ -1544,4 +1544,5 @@ MODULE_ENTRY (xpm, fill_info) (GdkPixbufFormat *info)
        info->mime_types = mime_types;
        info->extensions = extensions;
        info->flags = 0;
+       info->license = "LGPL";
 }